package com.xxxcompany.world.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import java.io.IOException;
import java.io.PrintWriter;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.xxxcompany.world.entity.City;
import com.xxxcompany.world.entity.Country;
import com.xxxcompany.world.service.IWorldService;
import com.xxxcompany.world.service.impl.WorldServiceImpl;

@WebServlet("/FindCountryCityServlet")
public class FindCountryCityServlet extends HttpServlet {
	IWorldService wService = new WorldServiceImpl();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		resp.setContentType("text/html;charset=utf-8");
		PrintWriter pw = resp.getWriter();
		
		List<City> list = wService.findCountryCity("ABK");

		pw.print("<table border=1>");
		for (City c : list) {
			pw.print("<tr>");
			pw.print("<td>" + c.getId() + "</td>");
			pw.print("<td>" + c.getName() + "</td>");
			pw.print("<td>" + c.getCountrycode() + "</td>");
			pw.print("</tr>");
		}
		pw.print("</table>");
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doGet(req, resp);
	}
}
